﻿@model Dish
@{
    ViewBag.Title = "菜肴维护";
    Layout = "~/Views/Shared/_LayoutFormDetail.cshtml";
}
@section Up{
    @Html.HiddenFor(model => model.Id)
    @Html.nbTextBoxFor(model => model.Name).Required()
    @Html.nbTextBoxFor(model => model.Code)
    @Html.nbDropDownListFor(model => model.MainMaterialType, "MaterialCategory")
    @Html.nbDropDownListFor(model => model.Category, "DishType")
    @Html.nbTextBoxFor(model => model.Cost).Number()
    @Html.nbTextAreaFor(model => model.Remark)
}
@section Down{
    @(Html.nbDetailFor<DishMaterial>(s =>
    {
        s.ID("MaterialList");
        s.layoutW(10);
        s.layoutH(285);
        s.Columns(c =>
        {
            c.Bind(e => e.Id).IsKey();
            c.Bind(e => e.NeedProcess).Hide();
            c.Bind(e => e.MaterialId).Hide();
            c.Bind(e => e.Code).Hide();
            c.BindEnum(e => e.Category, "MaterialCategory");
            c.BindControl(e => e.MaterialType).Width(50);
            c.Bind(e => e.Name).Width(80);
            c.Bind(e => e.CurrentPrice).Width(50).Align(GridAlign.Right);
            c.BindEnum(e => e.Unit, "MaterialUnit");
            c.BindControl(e => e.Weight).Align(GridAlign.Right).Width(50);
            c.Bind(e => e.Cost).Width(50).Align(GridAlign.Right);
            c.BindTemplate(60).Template(Url.GridRowClientDeleteLink());
        });
        s.Buttons(b =>
        {
            b.BindAddButton("添加品名").OnClick("SelectMaterial");
        });
    }))
}
<script type="text/javascript">
    function SelectMaterial(e) {
        OpenModalDialog('@Url.Action("LookUp", "Material")',
        {
            width: 800,
            height: 500,
            type: 2,
            onclose: function (MaterialData) {
                if (MaterialData) {
                    $("#MaterialList").flexAddRows(MaterialData);
                }
            }
        });
    }
</script>
